#ifndef _UIRESPONDER_PRIVATE_H_
#define _UIRESPONDER_PRIVATE_H_

#include <QGraphicsEllipseItem>
#include <QBasicTimer>
#include <QObject>
class QGraphicsSceneMouseEvent;
class QGraphicsItem;

#include "UITouch.h"
class UIWindow;

typedef enum {
    UIFlickStateSteady,
    UIFlickStatePressed,
    UIFlickStateManualScroll,
    UIFlickStateAutoScroll,
    UIFlickStateStop
} UIFlickEventState;

class UIResponder;
class UIResponderPrivate : public QObject {
    Q_OBJECT

    public:
        UIResponderPrivate (UIResponder *responder,
                            UIWindow *window,
                            QGraphicsItem *view);
        ~UIResponderPrivate();

        void touchesBegan (QGraphicsSceneMouseEvent *event);
        void touchesMoved (QGraphicsSceneMouseEvent *event);
        void touchesEnded (QGraphicsSceneMouseEvent *event);

        bool flickBegan (QGraphicsSceneMouseEvent *event);
        bool flickMoved (QGraphicsSceneMouseEvent *event);
        bool flickEnded (QGraphicsSceneMouseEvent *event);

        void setScrollEnabled (bool enabled) { m_scrollEnabled = enabled; }
        bool scrollEnabled (void) const { return(m_scrollEnabled); }

        bool handleTouches (void) const { return(m_handleTouches); }
        void setTouchesEnabled (bool enabled) { m_handleTouches = enabled; }

        void showTapArea (UITouch *touch);

    protected:
        void timerEvent (QTimerEvent *event);

    private:
        void touchEvent (void);
        void flickEvent (void);

    private:
        UIFlickEventState m_flickState;
        QBasicTimer m_flickTimer;
        QPointF m_flickTouchPos;
        QTime m_flickTimestamp;
        QPointF m_flickOffset;
        QPointF m_flickDelta;
        QPointF m_flickSpeed;
        bool m_scrollEnabled;

        QBasicTimer m_touchTimer;
        bool m_handleTouches;
        UITouch m_touchEvent;

        QGraphicsEllipseItem m_tapItem;
        QBasicTimer m_tapItemTimer;

        UIResponder *m_responder;
};

#endif /* !_UIRESPONDER_PRIVATE_H_ */

